package com.wtf.config;


import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * desc:
 *
 * @author tengfei wang
 * @version 1.0
 * @date Created in 11/10/2020
 */
@Component
public class SpringContextUtils implements ApplicationContextAware {

    private static ApplicationContext context = null;

    public SpringContextUtils() {
        super();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }

    public Object getBean(String name) {
        return context.getBean(name);
    }

    public Object getBean(Class<?> clazz) {
        return context.getBean(clazz);
    }
}
